﻿#ifndef MYSCENE_H
#define MYSCENE_H

#include <QWidget>
#include "config.h"
#include "grid.h"
#include "redtimer.h"
#include "statusicon.h"
#include <QMouseEvent>
#include <QTimer>



class MyScene : public QWidget
{
    Q_OBJECT
public:
    explicit MyScene(QWidget *parent = 0);



    Grid *singleGrid[50][50];
    RedTimer *leftTimer[3];
    RedTimer *rightTimer[3];
    StatusIcon *centreIcon;
    QDialog *failureWindow;
    QDialog *winWindow;


    void mousePressEvent(QMouseEvent *event);
    void closeEvent(QCloseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);
    void timerEvent(QTimerEvent *event);

    int mineNum;
    int markedNum;
    bool isStop;
    bool isBegin;
    QTimer m_Timer;
    int id = startTimer(1000);

    int leftNum;
    int rightNum;

    int restTime = 1000;



signals:
    void doubleClickSignal(int x,int y);
    void simulateLeftClickSignal(int x, int y);
    void simulateRightClickSignal(int x, int y);
    void statusIconClicked();
    void boom();
    void exitWin();
    void mousePush(int x, int y);
    void mouseMovePush(int x, int y);
    void beginGame();


public slots:
    void initScene();
    void refreshScene();
    void leftClickSlot(int x, int y);
    void rightClickSlot(int x, int y);
    void gridSet(int x, int y);
    void stopGame();
    void statusIconSlot();
    void mouseMoveGridPushAndPop(int x, int y);
    void forceTimer();
    void checkWin();
    void setRightNumber();
    void setLeftNumber();
    void setSingleNumber(int x, RedTimer *timeNum);
};

#endif // MYSCENE_H
